﻿namespace LinkedTU.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;

    public class GroupMembership : BaseDbEntity
    {
        public DateTime? LeavedOn { get; set; }

        [Key]
        [Column(Order = 1)]
        [ForeignKey("User")]
        public string UserId { get; set; }

        public virtual ApplicationUser User { get; set; }

        [Key]
        [Column(Order = 2)]
        [ForeignKey("Group")]
        public int GroupId { get; set; }

        public virtual Group Group { get; set; }

        [NotMapped]
        public bool IsActive
        {
            get
            {
                return !this.LeavedOn.HasValue;
            }
        }

    }
}
